package cn.com.generaldata.os.ws1.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigProperties {

	private static String urlAddress;
	private static String flag;

	public static String getFlag() {
		return flag;
	}

	public static String getUrlAddress() {
		return urlAddress;
	}

	static {
		try {
			Properties env = new Properties();
			InputStream inStream = ConfigProperties.class.getResourceAsStream("config.properties");
			Properties property = new Properties();
			property.load(inStream);
			urlAddress = property.getProperty("urlAddress");
			flag = property.getProperty("urlAddress");

			env.load(inStream);
			inStream.close();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * ֵ
	 * 
	 * @param propertyName
	 * @return
	 */
	public static String getPropertyByName(String propertyName) {
		String res = null;

		Properties env = new Properties();
		InputStream inStream = ConfigProperties.class.getResourceAsStream("config.properties");
		try {
			Properties property = new Properties();
			property.load(inStream);
			res = property.getProperty(propertyName);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (env != null) {
					env.load(inStream);
				}
				if (inStream != null) {
					inStream.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}

		}
		return res;
	}
}
